namespace ESupervision.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class MeetingModels : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.MeetingEvent",
                c => new
                    {
                        MeetingEventID = c.Int(nullable: false, identity: true),
                        Status = c.Int(nullable: false),
                        Subject = c.String(nullable: false, maxLength: 1000),
                        Body = c.String(nullable: false, maxLength: 4000),
                        OrganizerUserID = c.String(nullable: false, maxLength: 128),
                        StartTime = c.DateTime(nullable: false),
                        EndTime = c.DateTime(nullable: false),
                        AlertTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.MeetingEventID)
                .ForeignKey("dbo.AspNetUsers", t => t.OrganizerUserID, cascadeDelete: true)
                .Index(t => t.OrganizerUserID);
            
            CreateTable(
                "dbo.MeetingNote",
                c => new
                    {
                        MeetingNoteID = c.Int(nullable: false, identity: true),
                        MeetingEventID = c.Int(nullable: false),
                        UserID = c.String(nullable: false, maxLength: 128),
                        CreatedTime = c.DateTime(nullable: false),
                        Note = c.String(nullable: false, maxLength: 4000),
                    })
                .PrimaryKey(t => t.MeetingNoteID)
                .ForeignKey("dbo.AspNetUsers", t => t.UserID, cascadeDelete: true)
                .ForeignKey("dbo.MeetingEvent", t => t.MeetingEventID, cascadeDelete: false)
                .Index(t => t.UserID)
                .Index(t => t.MeetingEventID);
            
            CreateTable(
                "dbo.MeetingEventParticipant",
                c => new
                    {
                        MeetingEventParticipantID = c.Int(nullable: false, identity: true),
                        MeetingEventID = c.Int(nullable: false),
                        RequestedUserID = c.String(maxLength: 128),
                    })
                .PrimaryKey(t => t.MeetingEventParticipantID)
                .ForeignKey("dbo.AspNetUsers", t => t.RequestedUserID)
                .ForeignKey("dbo.MeetingEvent", t => t.MeetingEventID, cascadeDelete: true)
                .Index(t => t.RequestedUserID)
                .Index(t => t.MeetingEventID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.MeetingEvent", "OrganizerUserID", "dbo.AspNetUsers");
            DropForeignKey("dbo.MeetingEventParticipant", "MeetingEventID", "dbo.MeetingEvent");
            DropForeignKey("dbo.MeetingEventParticipant", "RequestedUserID", "dbo.AspNetUsers");
            DropForeignKey("dbo.MeetingNote", "MeetingEventID", "dbo.MeetingEvent");
            DropForeignKey("dbo.MeetingNote", "UserID", "dbo.AspNetUsers");
            DropIndex("dbo.MeetingEvent", new[] { "OrganizerUserID" });
            DropIndex("dbo.MeetingEventParticipant", new[] { "MeetingEventID" });
            DropIndex("dbo.MeetingEventParticipant", new[] { "RequestedUserID" });
            DropIndex("dbo.MeetingNote", new[] { "MeetingEventID" });
            DropIndex("dbo.MeetingNote", new[] { "UserID" });
            DropTable("dbo.MeetingEventParticipant");
            DropTable("dbo.MeetingNote");
            DropTable("dbo.MeetingEvent");
        }
    }
}
